package org.dfg.corejava.designPattern.thread.lock;

import java.nio.ByteBuffer;
import java.util.concurrent.locks.ReentrantLock;

public class LockTestWriter extends Thread {
	private ByteBuffer bb;
	private ReentrantLock lock;

	public LockTestWriter(ByteBuffer bb, ReentrantLock lock) {
		this.bb = bb;
		this.lock = lock;
	}

	@Override
	public void run() {// 模拟写，假设一直未释放
		lock.lock();//获取锁
		try {
			int i = 0;
			while (i < 1) {
			}
			System.out.println("write end");
		} finally {
			lock.unlock();//释放锁
		}
	}
}
